// const nums = [0,1,2,2,3,0,4,2] 
nums =[3,2,2,3]
const val = 3


var removeElement = function(nums, val) {
    if(nums.length===0)
    {
        return 0
    }
     let i=0;
     let len=nums.length;
     while(i<len)
     {
        if(nums[i]==val)
        {
            nums[i]=nums[len-1]
            len--
        }
        else{
          i++
        } 
        
     }
     return len


}(nums,val)
console.log(nums)
console.log(removeElement)
